#include<stdio.h>
void to_binary(unsigned long n ,int m);
int main (void)
{
	unsigned long number;
	int num;
	printf("Enter an interger (q to quit):\n");
	while(scanf("%lu %d",&number,&num) == 2)
	{
		printf("Binary equivalent: ");
		to_binary(number, num);
		putchar('\n');
		printf("Enter an integer (q to quit):\n");

	}
	printf("Done!\n");
	
	return 0;
} 
void to_binary(unsigned long n, int m)
{
	int r;
	r = n%m;
	if(n>=m)
	{
		to_binary( n/m, m);
	}
	printf("%d",r);
}